package snaptest.repo;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

class FileDirSplitter {

	private final List<String> textFiles = new ArrayList<String>();
	
	private final List<String> subDirs = new ArrayList<String>();
	
	private final String rootDir;
	
	public FileDirSplitter(String rootDir) {
		this.rootDir = rootDir;
		split();
	}

	private void split() {
		for(String entry:listRootDir()) {
			String entryPath = rootDir + "/" + entry;
			if (entry.startsWith(".")) {
				// don't care about hidden directories.
			} else if (new File(entryPath).isDirectory()) {
				subDirs.add(entryPath);
			} else if (entryPath.endsWith(".txt")) {
				textFiles.add(entryPath);
			}
		}
	}

	private String[] listRootDir() {
		return new File(rootDir).list();
	}

	public List<String> getTextFiles() {
		return textFiles;
	}

	public List<String> getSubDirs() {
		return subDirs;
	}
	
}
